package com.example.framework;

import java.util.*;

public class Folders {
    private List<String> cachedFolders = null;

    public Folders(List<String> folders){
        this.cachedFolders = new ArrayList<String>(folders);
    }

    public Folders withAdded(String folder) {
        Folders newList = new Folders(cachedFolders);
        newList.cachedFolders.add(folder);
        return newList;
    }

    public Folders without(String folder) {
        Folders newList = new Folders(cachedFolders);
        newList.cachedFolders.remove(folder);
        return newList;
    }
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Folders folders = (Folders) o;

        if (cachedFolders != null ? !cachedFolders.equals(folders.cachedFolders) : folders.cachedFolders != null)
            return false;

        return true;
    }

    @Override
    public int hashCode() {
        return cachedFolders != null ? cachedFolders.hashCode() : 0;
    }

    @Override
    public String toString() {
        return "Folders{" + cachedFolders + '}';
    }
}
